package com.web.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.web.model.UserInfo;
import com.web.service.UserService;

@Controller
@RequestMapping(value = "user")
public class UserController {
	
	@Autowired
	private UserService userService;
	
	@RequestMapping("login/{userAccount}/{password}/{isNewUser}")
	@ResponseBody
	public UserInfo login(@PathVariable("userAccount")String userAccount,@PathVariable("password")String password,@PathVariable("isNewUser")boolean isNewUser){
		UserInfo user = new UserInfo();
		user.setUserAccount(userAccount);
		user.setPassword(password);
		if (isNewUser) {
			return userService.insertUser(user);
		}
		return user;
	}

}
